home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / CronVixie2.1 / atinmin next >
Text File  |  1995-06-12  |  1KB  |  29 lines

  1. #!/usr/local/bin/perl
  2. # vi:se wm=0 sw=4 ts=4:
  3. # run an "at" job N minutes from now, from the command line
  4. # Copyright 1992 Irving_Wolfe@Happy-Man.com.  Permission is hereby granted,
  5. # provided that this notice and my ad at the bottom are not removed, for 
  6. # unlimited internal use and no-charge redistribution to anyone.  If you 
  7. # change it, please add a line mentioning that you did so.
  8.  
  9. $sec = 60 * shift;
  10. die "usage: $0 minutes <rest of at command>,\n quitting" unless $sec > 0;
  11.  
  12. # build the command to run and arrange to get its output by mail
  13. $rawCmd = join(' ', @ARGV);
  14. ($user, $junk) = getpwuid($>);
  15. $runCmd = "F=/tmp/am\$\$;export F;$rawCmd 2>&1 >\$F;if test -s \$F;then <\$F /usr/ucb/Mail -n -s 'atjob: $rawCmd' $user;fi;rm -f \$F";
  16.  
  17. # build the "at" command
  18. ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time + $sec);
  19. $mon = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$mon];
  20. $atCmd = sprintf(qq/|at -s %02d%02d %s %d/, $hour, $min, $mon, $mday);
  21. open(atCmd) || die "$0: could not open $atCmd,\n quitting";
  22.  
  23. print atCmd "$runCmd\n";
  24. __END__
  25. # Irving_Wolfe@Happy-Man.com      Happy Man Corp. 206/463-9399 x101
  26. # 4410 SW Pt. Robinson Rd., Vashon Island, WA  98070-7399  fax x108
  27. # We publish SOLID VALUE for the intelligent investor.  NextMail OK
  28. #Info free; sample $20: Send POSTAL addr: Solid-Value@Happy-Man.com
  29.